<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<html>
<head>
	<title>内部订单管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/bu/buInternalOrder/">内部订单列表</a></li>
		<shiro:hasPermission name="bu:buInternalOrder:operate:edit"><li><a href="${ctx}/bu/buInternalOrder/form?flag=1&write=0">内部订单添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="buOrder" action="${ctx}/bu/buInternalOrder/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>订单编号：</label>
				<form:input path="orderNo" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>生成编号：</label>
				<form:input path="productNo" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>出货日期：</label>
				<input name="shipDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${buOrder.shipDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</li>
			<li><label>下单日期：</label>
				<form:input path="orderDate" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>产品名称：</label>
				<form:input path="productName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li>
				<label>订单状态：</label>
				<select id="orderState" name="orderState">
				        <option value="">--请选择--</option>
						<c:forEach items="${fns:getDictList('order_state')}" var="dict">
							<option value="${dict.value}" ${dict.value==order_state?'selected':''}>${dict.label}</option>
						</c:forEach>
					</select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>订单编号</th>
				<th>生成编号</th>
				<th>下单日期</th>
				<th>出货日期</th>
				<th>产品名称</th>
				<td>图片</td>
				<td>抛光</td>
				<th>工艺</th>
				<th>背面</th>
				<th>包装</th>
				<th>配件</th>
				<th>数量</th>
				<th>销售单价</th>
				<th>销售模费</th>
				<th>生产单价</th>
				<th>生产模费</th>
				<th>销售总价</th>
				<th>生产总价</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="buOrder">
			<tr>
				<td><a href="${ctx}/bu/buInternalOrder/view?id=${buOrder.id}&flag=2&write=0">
					${buOrder.orderNo}
				</a><input type="hidden" value="${buOrder.salesmanId}"/></td>
				<td>
					${buOrder.productNo}
				</td>
				<td>
				    ${buOrder.orderDate}
				</td>
				<td>
					<fmt:formatDate value="${buOrder.shipDate}" pattern="yyyy-MM-dd"/>
				</td>
				<td>
					${buOrder.productName}
				</td>
				<td><img alt="" src="${urlPreffix}${buOrder.picUrl}" style="width: 40px;height: 40px;"></td>
				<td>${buOrder.polishing}</td>
				<td>
					${buOrder.crafts}
				</td>
				<td>
					${buOrder.back}
				</td>
				<td>
					${buOrder.packages}
				</td>
				<td>
					${buOrder.fitting}
				</td>
				<td>
					${buOrder.quantity}
				</td>
				<td>
					${buOrder.salesPrice}
				</td>
				<td>
					${buOrder.salesModelFee}
				</td>
				<td>
					${buOrder.produceFee}
				</td>
				<td>
					${buOrder.produceModelFee}
				</td>
				<td>
					${buOrder.salesTotalFee}
				</td>
				<td>
					${buOrder.produceTotalFee}
				</td>
				<td>
					<c:if test="${buOrder.orderState == 1000}">待审核</c:if>
					<c:if test="${buOrder.orderState == 1001}">待生产</c:if>
					<c:if test="${buOrder.orderState == 1002}">生产中</c:if>
					<c:if test="${buOrder.orderState == 1003}">待发货</c:if>
					<c:if test="${buOrder.orderState == 1004}">待收货</c:if>
					<c:if test="${buOrder.orderState == 1005}">待收款</c:if>
					<c:if test="${buOrder.orderState == 1006}">已完成</c:if>
				</td>	
				<td><a href="${ctx}/bu/buInternalOrder/view?id=${buOrder.id}&flag=2&write=0">查看</a>
					    <c:if test="${buOrder.orderState == 1000}">
					    	<shiro:hasPermission name="bu:buInternalOrder:operate:ios0">
					    		<a href="${ctx}/bu/buInternalOrder/updateDelivery?id=${buOrder.id}&flag=3&write=0" onclick="return confirmx('确认操作该条订单数据吗？', this.href)">审核</a>
					    	</shiro:hasPermission>
					    </c:if>
					    <c:if test="${buOrder.orderState == 1001}">
					    	<shiro:hasPermission name="bu:buInternalOrder:operate:ios1">
					       		<a href="${ctx}/bu/buInternalOrder/updateDelivery?id=${buOrder.id}&flag=3&write=0" onclick="return confirmx('确认操作该条订单数据吗？', this.href)">确认生产</a>
					        </shiro:hasPermission>
					        <shiro:hasPermission name="bu:buInternalOrder:operate:export">
					        	<a href="${ctx}/bu/buInternalOrder/exportProductFile?id=${buOrder.id}" onclick="return confirmx('确认要下载数据吗？', this.href)">下载生产单</a>	
					        </shiro:hasPermission>
					    </c:if>
					    <c:if test="${buOrder.orderState == 1002}">
					    	<shiro:hasPermission name="bu:buInternalOrder:operate:ios2">
					       		<a href="${ctx}/bu/buInternalOrder/updateDelivery?id=${buOrder.id}&flag=3&write=0" onclick="return confirmx('确认操作该条订单数据吗？', this.href)">生产完成</a>
					    	</shiro:hasPermission>
					    </c:if>
					    <c:if test="${buOrder.orderState == 1003}">
					       <shiro:hasPermission name="bu:buInternalOrder:operate:ios3">
					       		<a href="${ctx}/bu/buInternalOrder/selectById?id=${buOrder.id}&flag=1&write=1" onclick="return confirmx('确认操作该条订单数据吗？', this.href)">发货</a>
					       </shiro:hasPermission>	
					    </c:if> 
					    <c:if test="${buOrder.orderState == 1004}">
					       <shiro:hasPermission name="bu:buInternalOrder:operate:ios4">
					       		<a href="${ctx}/bu/buInternalOrder/updateDelivery?id=${buOrder.id}&flag=3&write=0" onclick="return confirmx('确认操作该条订单数据吗？', this.href)">确认收货</a>
					       </shiro:hasPermission>	
					    </c:if>  
					    <c:if test="${buOrder.orderState == 1005}">
					       <shiro:hasPermission name="bu:buInternalOrder:operate:ios5">
					        	<a href="${ctx}/bu/buInternalOrder/updateDelivery?id=${buOrder.id}&flag=3&write=0" onclick="return confirmx('确认操作该条订单数据吗？', this.href)">确认收款</a>
					    	</shiro:hasPermission>
					    </c:if>
					     <c:if test="${buOrder.orderState == 1006}">
					       	<shiro:hasPermission name="bu:buInternalOrder:operate:copy">
						  		<a href="${ctx}/bu/buInternalOrder/copy?id=${buOrder.id}&flag=3&write=0">追加</a>
							</shiro:hasPermission>
					    </c:if>    
					 <c:if test="${buOrder.orderState == 1001 || buOrder.orderState == 1002}">
					 	<shiro:hasPermission name="bu:buInternalOrder:operate:toUpdate">
							<a href="${ctx}/bu/buInternalOrder/toUpdate?id=${buOrder.id}&flag=1&write=0">修改</a>
					 	</shiro:hasPermission>
					 </c:if>   
					 <shiro:hasPermission name="bu:buInternalOrder:operate:delete">
						<a href="${ctx}/bu/buInternalOrder/delete?id=${buOrder.id}" onclick="return confirmx('确认要删除该条数据吗？', this.href)">删除</a>
					 </shiro:hasPermission>
				</td>			
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<script type="text/javascript">
	function addDelivery(href){
							top.$.jBox.open('iframe:'+href,'填写快递信息',$(top.document).width()-220,$(top.document).height()-180,{
								buttons:{"关闭":true},
								loaded:function(h){
									$(".jbox-content", top.document).css("overflow-y","hidden");
									$(".nav,.form-actions,[class=btn]", h.find("iframe").contents()).hide();
									$("body", h.find("iframe").contents()).css("margin","10px");
								}
							});
							return false;
						}
	
	</script>
</body>
</html>